package com.qgs.secsgem.secs.controller.pid24a;

import com.qgs.secsgem.secs.eqsimulator.PID24aSimulator;
import com.qgs.secsgem.secs.secs2.Secs2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/testPID24aEAPClient")
public class PID24aEquipmentTestPushController {
    private static final Logger logger = LoggerFactory.getLogger(PID24aEquipmentTestPushController.class);
    @Autowired
    private PID24aSimulator simulator;

    @PostMapping("/S6F11")
    public void S6F11(
            @RequestBody EQEventParam param
    ) throws Exception {
        //build s6f11
        Secs2 s6f11 = Secs2.list(
                Secs2.uint4(1)      //dataid
                , Secs2.int4(21)  //ceid
                , Secs2.list(
                        Secs2.list(
                                Secs2.uint4(10171),  //reportId
                                Secs2.list(
                                        Secs2.ascii(param.getReceiveTime())
                                        ,Secs2.float4(param.getPowerConfus())
                                )
                        )
                )
        );
        System.out.println("s6f11 is ready to send: \n"+s6f11.toString());
        try {
            simulator.getComm().send(6,11,true,s6f11);
        }catch (Exception e){

        }
        System.out.println("s6f11 is sended: \n"+s6f11.toString());
    }



}
